/*
 *   Author:         Kirin Zhong
 *   Created Date:   2024/5/20
 *
 *   Updated Date    Updated By      Reason of Update
 *   ------------    -----------     -----------------------------------------------
 */
package org.kirin.ocr.util;

import org.apache.commons.lang3.StringUtils;

import java.util.Scanner;

public class CamelCaseConverterUtil {
    private CamelCaseConverterUtil(){}

            public static String toCamelCase(String input) {
                if (input == null || input.isEmpty()) {
                    return input;
            }
        // 将输入字符串转换为小写，然后按非字母数字字符进行分割
        String[] words = input.toLowerCase().split("[^a-zA-Z0-9]+");
        StringBuilder camelCaseOutput = new StringBuilder(words[0]);
        // 第一个单词之后的每个单词首字母大写
        for (int i = 1; i < words.length; i++) {
            camelCaseOutput.append(StringUtils.capitalize(words[i]));
        }
        return camelCaseOutput.toString();
    }

    public static void main(String[] args) {
        while (true){
            String input = new Scanner(System.in).next();
            input = StringUtils.uncapitalize(input).replaceAll("([a-z])([A-Z])", "$1_$2");
            System.out.println(input.toLowerCase());
        }
    }
}
